<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"
	default-lazy-init="true">

	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
		<property name="securityManager" ref="securityManager" />
		<property name="loginUrl" value="/admin/login.jsp" />
		<property name="successUrl" value="/admin/common/main.jhtml" />
		<property name="unauthorizedUrl" value="/admin/common/unauthorized.jhtml" />
		<property name="filterChainDefinitions">
			<value>
				/admin/ = anon
				/admin/index.jsp = anon
				/admin/login.jsp = authc
				/admin/logout.jsp = logout
				/admin/common/captcha.jhtml = anon

				/admin/product/** = perms["admin:product"]
				/admin/product_category/** = perms["admin:productCategory"]
				/admin/parameter_group/** = perms["admin:parameterGroup"]
				/admin/attribute/** = perms["admin:attribute"]
				/admin/specification/** = perms["admin:specification"]
				/admin/brand/** = perms["admin:brand"]
				/admin/product_notify/** = perms["admin:productNotify"]
				/admin/phone_data/** = perms["admin:phoneimp"]

				/admin/order/** = perms["admin:order"]
				/admin/print/** = perms["admin:print"]
				/admin/payment/** = perms["admin:payment"]
				/admin/refunds/** = perms["admin:refunds"]
				/admin/shipping/** = perms["admin:shipping"]
				/admin/returns/** = perms["admin:returns"]
				/admin/delivery_center/** = perms["admin:deliveryCenter"]
				/admin/delivery_template/** = perms["admin:deliveryTemplate"]
				/admin/chargelog/** = perms["admin:chargelog"]

				/admin/member/** = perms["admin:member"]
				/admin/member_rank/** = perms["admin:memberRank"]
				/admin/member_attribute/** = perms["admin:memberAttribute"]
				/admin/review/** = perms["admin:review"]
				/admin/consultation/** = perms["admin:consultation"]

				/admin/navigation/** = perms["admin:navigation"]
				/admin/article/** = perms["admin:article"]
				/admin/article_category/** = perms["admin:articleCategory"]
				/admin/tag/** = perms["admin:tag"]
				/admin/friend_link/** = perms["admin:friendLink"]
				/admin/ad_position/** = perms["admin:adPosition"]
				/admin/ad/** = perms["admin:ad"]
				/admin/template/** = perms["admin:template"]
				/admin/cache/** = perms["admin:cache"]
				/admin/static/** = perms["admin:static"]
				/admin/index/** = perms["admin:index"]

				/admin/promotion/** = perms["admin:promotion"]
				/admin/coupon/** = perms["admin:coupon"]
				/admin/seo/** = perms["admin:seo"]
				/admin/sitemap/** = perms["admin:sitemap"]

				/admin/statistics/** = perms["admin:statistics"]
				/admin/sales/** = perms["admin:sales"]
				/admin/sales_ranking/** = perms["admin:salesRanking"]
				/admin/purchase_ranking/** = perms["admin:purchaseRanking"]
				/admin/deposit/** = perms["admin:deposit"]

				/admin/setting/** = perms["admin:setting"]
				/admin/area/** = perms["admin:area"]
				/admin/payment_method/** = perms["admin:paymentMethod"]
				/admin/shipping_method/** = perms["admin:shippingMethod"]
				/admin/delivery_corp/** = perms["admin:deliveryCorp"]
				/admin/payment_plugin/** = perms["admin:paymentPlugin"]
				/admin/storage_plugin/** = perms["admin:storagePlugin"]
				/admin/admin/** = perms["admin:admin"]
				/admin/role/** = perms["admin:role"]
				/admin/message/** = perms["admin:message"]
				/admin/log/** = perms["admin:log"]
											
				/admin/departure/** = perms["admin:departure"]
				/admin/destination/** = perms["admin:destination"]
				/admin/editor_template/** = perms["admin:editor_template"]
				
				/admin/** = authc
			</value>
		</property>
		<property name="filters">
			<map>
				<entry key="authc" value-ref="authenticationFilter" />
				<entry key="logout" value-ref="logoutFilter" />
			</map>
		</property>
	</bean>

	<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
		<property name="realm" ref="authenticationRealm" />
		<property name="cacheManager" ref="shiroCacheManager" />
	</bean>

	<bean id="authenticationRealm" class="com.finalist.AuthenticationRealm">
		<property name="authorizationCacheName" value="authorization" />
	</bean>

	<bean id="shiroCacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
		<property name="cacheManager" ref="ehCacheManager" />
	</bean>

	<bean id="authenticationFilter" class="com.finalist.filter.AuthenticationFilter" />
	<bean id="logoutFilter" class="org.apache.shiro.web.filter.authc.LogoutFilter">
        <property name="redirectUrl" value="/admin/login.jsp" />
    </bean> 

	<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
		<property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager" />
		<property name="arguments" ref="securityManager" />
	</bean>

</beans>